<?php
class ModelToolOnline extends Model {	
	public function whosonline($ip, $user_id, $url, $referer) {
        $update = $this->pdo->prepare("DELETE FROM " . $this->db_prefix . "customer_online 
            WHERE (UNIX_TIMESTAMP(date_added) + 3600) < UNIX_TIMESTAMP(NOW())");

        $update->execute();
		 
        $update = $this->pdo->prepare("REPLACE INTO " . $this->db_prefix . "customer_online SET 
            ip          = :ip, 
            user_id = :user_id, 
            url         = :url, 
            referer     = :referer, 
            date_added  = NOW()");

        $update->execute(array(
            ':ip'           => $ip, 
            ':user_id'  => (int) $user_id, 
            ':url'          => $url, 
            ':referer'      => $referer
        ));

	}
}
?>
